#!/sbin/openrc-run

description="Jitsi Videobridge"

pidfile="/run/jvb/jvb.pid"
# launcher script below will work on OpenRC also
command="/usr/lib/jitsi-videobridge/jvb.sh"
command_args="${JVB_OPTS}"
command_user="jvb:jitsi"
command_background=true

depend() {
	need net
	want jabber-server
}

start_pre() {
	checkpath -d -m 770 -o $command_user /run/jvb
}

start() {
	ebegin "Starting ${name}"
	start-stop-daemon --start --quiet --background --chuid $command_user \
		-m --pidfile $pidfile \
		--exec /bin/bash -- -c "JAVA_SYS_PROPS=\"$JAVA_SYS_PROPS\" exec $command $command_args >> $JVB_LOGFILE 2>&1"
	eend $?
}

